/*
 * @Author: jianfanfan 是是是
 * @Date: 2025-09-05 10:32:24
 * @LastEditors: jianfanfan 是是是
 * @LastEditTime: 2025-09-12 10:44:56
 * @FilePath: \nest-project\src\aaa\aaa.controller.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  HostParam,
  Req,
  Redirect,
  Header,
  Version,
} from '@nestjs/common';
import { AaaService } from './aaa.service';
import { CreateAaaDto } from './dto/create-aaa.dto';
import { UpdateAaaDto } from './dto/update-aaa.dto';
import type { Request } from 'express';

@Controller({ host: ':host.0.0.1', path: 'aaa', version: 'v1' })
export class AaaController {
  constructor(private readonly aaaService: AaaService) {}

  @Post()
  create(@Body() createAaaDto: CreateAaaDto) {
    return this.aaaService.create(createAaaDto);
  }

  @Get()
  findAll() {
    return this.aaaService.findAll();
  }

  @Version('v2')
  @Get()
  findAllV2() {
    return this.aaaService.findAll();
  }

  //   @Get(':id')
  //   findOne(@Param('id') id: string) {
  //     return this.aaaService.findOne(+id);
  //   }

  //   @Patch(':id')
  //   update(@Param('id') id: string, @Body() updateAaaDto: UpdateAaaDto) {
  //     return this.aaaService.update(+id, updateAaaDto);
  //   }

  //   @Delete(':id')
  //   remove(@Param('id') id: string) {
  //     return this.aaaService.remove(+id);
  //   }

  @Get('bbb')
  hello(@HostParam('host') host: string) {
    return host;
  }

  @Get('ccc')
  @Header('aaa', 'bbb')
  //   @Redirect('https://www.baidu.com')
  ccc(@Req() req: Request) {
    console.log(req.hostname);
    console.log(req.url);
  }
}
